package cn.example.backstage.appointment.controller;

import cn.example.backstage.appointment.pojo.dto.AppointmentAddDTO;
import cn.example.backstage.appointment.pojo.dto.AppointmentQuery;
import cn.example.backstage.appointment.pojo.vo.AppointmentVO;
import cn.example.backstage.base.response.JsonResult;
import cn.example.backstage.appointment.service.AppointmentRegisterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/appointmentRegister")
public class AppointmentRegisterController {
    @Autowired
    AppointmentRegisterService appointmentRegisterService;
    @GetMapping("select")
    public JsonResult selectAppointment(AppointmentQuery appointmentQuery){
        List<AppointmentVO> list = appointmentRegisterService.selectAll(appointmentQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("add")
    public JsonResult addAppointment(@RequestBody AppointmentAddDTO appointmentAddDTO){
        appointmentRegisterService.addAppointment(appointmentAddDTO);
        return JsonResult.ok();
    }
    @DeleteMapping("delete/{id}")
    public JsonResult deleteAppointment(@PathVariable Long id){
        appointmentRegisterService.deleteById(id);
        return JsonResult.ok();
    }
}